package com.example.mapper;

import com.example.pojo.Materials;
import com.example.pojo.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface MaterialMapper {

    Long count(String materialName, int stockQuantity);

    List<Materials> page(Integer start, Integer pageSize, String materialName, int stockQuantity);

    @Insert("insert into materials (materialName,stockQuantity,unit) values (#{materialName},0,#{unit})")
    void add(Materials materials);

    @Update("update materials set stockQuantity= stockQuantity+#{stockQuantity} where materialID = #{materialID}")
    void update(Materials materials);

    void deletes(List<Integer> ids);
@Select("select * from materials")
    List<Materials> selectIDs();
    @Update("update materials set stockQuantity= stockQuantity+#{quantity} where materialID = #{materialID}")
    void updates(Order order);
@Select("select * from materials where materialName = #{materialName}")
    Materials getOne(String metrname);
@Select("select minput from materials where materialID = #{materialID}")
    int getprice(int materialID);
@Select("select stockQuantity from materials where materialName = #{name}")
    int getcun(String name);
@Select("select materialName from materials where materialID = #{materialID}")
    String getName(int materialID);
@Update("update materials set stockQuantity=stockQuantity-#{num} where materialName = #{name}")
    void updatese(String name, int num);
@Select("select minput from materials where materialName=#{name}")
    int getprices(String name);
    @Select("select unit from materials where materialName=#{name}")
    String getunit(String name);
}
